<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
		<link rel="stylesheet" href="../../../layuiadmin/layui/css/layui.css" media="all">
		<link rel="stylesheet" href="../../../layuiadmin/style/admin.css" media="all">
		<link rel="stylesheet" href="../../../css/common.css" media="all">
		<style type="text/css">
			.content {
				width: 80%;
				height: 350px;
				overflow-y: scroll;
				padding: 0 10px;
			}
			
			/*滚动条样式*/
			
			.content::-webkit-scrollbar {
				width: 4px;
				/*height: 4px;*/
			}
			.content-topo::-webkit-scrollbar{
				width: 0;
			}
			
			.content::-webkit-scrollbar-thumb {
				border-radius: 10px;
				-webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
				background: rgba(0, 0, 0, 0.2);
			}
			.content-topo::-webkit-scrollbar-thumb {
				border-radius: 0px;
				-webkit-box-shadow: inset 0 0 0 rgba(0, 0, 0, 0);
				background: rgba(0, 0, 0, 0);
			}
			.content::-webkit-scrollbar-track {
				-webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
				border-radius: 0;
				background: rgba(0, 0, 0, 0.1);
			}
			.content-topo::-webkit-scrollbar-track {
				-webkit-box-shadow: inset 0 0 0 rgba(0, 0, 0, 0);
				border-radius: 0;
				background: rgba(0, 0, 0, 0);
			}
			.layui-card .froum {
				background-color: #ccc;
			}
			.forum-top {
				margin-bottom: 20px;
			}
			.forum-le{
				float: left;
				width: 35px;
				height: 35px;
				border-radius: 50%;
				background-color: #000000
			}
			.forum-ri{
				padding-top: 5px;
				margin-left: 50px;
			}
			.bc-forum{
				padding: 10px;
			}
			.bc-forum-to{
				padding: 10px;
			}
			.forum-box-o{
				font-size: 16px;
			}
			.forum-box-t {
				font-size: 14px;
				color: #888;
			}
			.forum-box-til{
				float: right;
				font-size: 12px;
				color: #888;
			}
			.forum-text {
				width: 100% !important;
			}
			.forum-le-to{
				float: right;
				width: 35px;
				height: 35px;
				border-radius: 50%;
				background-color: #000000
			}
			.forum-box-til-to{
				float: left;
				font-size: 12px;
			}
			.forum-ri-to{
				padding-top: 5px;
				margin-right: 50px;
				overflow: hidden;
			}
			.forum-box-o-to{
				float: right;
				font-size: 16px;
			}
			.forum-top-to{
				margin-bottom: 20px;
				overflow: hidden;
			}
			.forum_view {
				background-color: #888 ;
			}
			.content-topo{
				height: 200px;
			}
			.content-ri{
				float: right;
			}
		</style>
	</head>

	<body>

		<div class="layui-fluid reporting_style">
			<div class="layui-row" id="view">

				<button type="button" class="layui-btn layui-btn-normal layui-btn-sm return">
					<i class="layui-icon layui-icon-return"></i>返回列表
				</button>

				<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
					<legend>工单详情</legend>
				</fieldset>
				<div class="layui-card">
					<div class="layui-card-body">
						<div class="layui-row layui-col-space15" id="detail_view"></div>

						<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
							<legend>聊天记录</legend>
						</fieldset>
						    
						<form class="layui-form test_edit" lay-filter="test_detail" id="fo">
							<div id="forum_view"></div>
							<!-- <div class="layui-row layui-col-space15" id="detail_view_sub"></div> -->

							<div class="layui-form-item">
								<input type="hidden" name="id" />

								<!--<label class="layui-form-label"></label>
								<div class="layui-input-inline">
									<input type="text" readonly name="persons_name" lay-verify="required" placeholder="请选择执行者" autocomplete="off"
									 class="layui-input project_name">
									<input type="hidden" name="persons_id" placeholder="" autocomplete="off" class="layui-input projectid">
								</div>
								<div class="layui-form-mid layui-word-aux people">
									<a href="Javascript:;" onclick="check('people')">选择</a>
								</div>-->
							</div>
					
							<div class="layui-form-item layui-layout-admin">
									<div class="layui-input-block">
										<div class="layui-footer" style="left: 0;">
											<button type="button" class="layui-btn layui-btn-normal" onclick="searchdata()">回复
											</button>
										</div>
									</div>
								</div>
							</div>
							
						</form>
					</div>
				</div>
			</div>
		</div>
		
		<script type="text/html" id="detail_view_script">
			<div class="layui-col-md4 flex">
				<span class="text_hs3_color">状态：</span>
				<span class="text_red_color">{{ d.status }}</span>
			</div>
			<div class="layui-col-md4">
				<span class="text_hs3_color">工单编号：</span>
				<span>{{ d.orderid }}</span>
			</div>
			<div class="layui-col-md4">
				<span class="text_hs3_color">优先级：</span>
				<span>{{ d.level }}</span>
			</div>
			<div class="layui-col-md4">
				<span class="text_hs3_color">会员：</span>
				<span>{{ d.membername + '('+ d.memberid +')' }}</span>
			</div>
			<div class="layui-col-md4">
				<span class="text_hs3_color">项目：</span>
				<span>{{ d.project_name + '('+ d.project_id +')' }}</span>
			</div>
			<div class="layui-col-md4">
				<span class="text_hs3_color">应用：</span>
				<span>{{ d.app_name + '('+ d.app_id +')' }}</span>
			</div>
			<div class="layui-col-md4">
				<span class="text_hs3_color">工时：</span>
				<span>{{ d.hours + '(小时)' }}</span>
			</div>
			<div class="layui-col-md4">
				<span class="text_hs3_color">费用：</span>
				<span>{{ d.fee }}</span>
			</div>
			<div class="layui-col-md4">
				<span class="text_hs3_color">预计完成时间：</span>
				<span>{{ d.scheduled_time }}</span>
			</div>
			<div class="layui-col-md4">
				<span class="text_hs3_color">备注：</span>
				<span>{{ d.notes || ''}}</span>
			</div>
			<div class="layui-col-md12 flex_none">
				<span class="text_hs3_color">问题描述：</span>
				<div class="content">{{ d.problem_desc }}</div>
			</div>
		</script>

		
		<script type="text/html" id="forum_view_script">
			<div class="forum-box">
			
				{{#  layui.each(d, function(index, item){ }}
				{{# if(item.type===1){ }}
					<div class="bc-forum">
						<div class="forum-le">
							<div class="forum-img"></div>
						</div>
						<div class="forum-ri">
							<div class="forum-top">
								<span class="forum-box-o">{{ item.username }}[{{item.membername}}]</span>
								<span class="forum-box-til">{{item.addtime}}</span>
							</div>
							<div class="content-topo content">{{ item.content }}</div>
						</div>
					</div>
					<hr >
					{{#
					  } else { }}
						<div class="bc-forum">
							<div class="forum-le-to">
								<div class="forum-img-to"></div>
							</div>
							<div class="forum-ri-to">
								<div class="forum-top-to">
									<span class="forum-box-o-to">{{ item.username }}[{{item.membername}}]</span>
									<span class="forum-box-til-to">{{item.addtime}}</span>
								</div>
								<div class="content-topo content content-ri">{{ item.content }}</div>
							</div>
						</div>
						<hr >
					{{#
					  } }} 
				{{#  }); }}
				
			
		</script>
		
		<script src="../../../layuiadmin/layui/layui.js"></script>
		<script src="../../../js/jquery.min.js"></script>
		<script src="../../../js/jquery.jqprint-0.3.js"></script>
		<script src="../../../js/common.js"></script>
		<script>
			
			var _data = {
				id: getParam('id'),
				orderid: getParam('orderid')
			}

			layui.config({
				base: '../../../layuiadmin/' //静态资源所在路径
			}).extend({
				index: 'lib/index' //主入口模块
			}).use(['index', 'form', 'laytpl', 'laydate'], function() {
				var $ = layui.$,
					admin = layui.admin,
					laytpl = layui.laytpl,
					laytpl_sub = layui.laytpl,
					laydate = layui.laydate,
					form = layui.form;

				var role_type = getParam('role_type')

				if(getParam('id')) {
					loading();
					initdata();
				}

				if(getParam('orderid')) {
					loading();
					initorder_sub();
				}

				//监听提交
				form.on('submit(demo1)', function(data) {
					var data = data.field;
					_data = Object.assign(_data, data);
					layer.confirm('确定要提交数据？', function() {
						loading();
						submitdata(wd_server.erp_work_order_designate);
					}, function() {
						layer.msg('取消操作');
					});

					return false;
				});

				function submitdata(_url) {
					$.post(_url, _data, function(res, status) {
						if(status == 'success') {
							if(res.code == 0) {
								layer.open({
									content: '操作成功',
									btn: ['继续操作', '返回列表'],
									btn2: function(index, layero) {
										window.history.back(-1);
									},
									btn1: function(index, layero) {
										layer.close(index)
										initdata()
									},
								});
							} else {
								layer.msg(res.msg);
							}
							closeloading();
						} else {
							closeloading();
							layer.msg('服务器连接错误');
						}
					});
				}

				var data_tpl1 = {};
				
				
				
				function initdata() {
					$.get(wd_server.erp_work_order_detail, _data, function(res, status) {
						if(status == 'success') {
							if(res.code == 0) {
								var data = res.erp_work_order
								
								if(data.data.status != 0) {
									$('.people').addClass('layui-hide')
								}
								data.data.level = map_show({
									mapName: 'work_order_level',
									data: data.data.level
								})
								data.data.status = map_show({
									mapName: 'work_order_status',
									data: data.data.status
								})
								var getTpl = detail_view_script.innerHTML,
									view = document.getElementById('detail_view');
								laytpl(getTpl).render(data.data, function(html) {
									view.innerHTML = html;
								});
							} else {
								layer.msg(res.msg);
							}
							layer.closeAll('loading')
						} else {
							layer.msg('服务器连接错误');
							layer.closeAll('loading')
						}
					});
				}
				// //对话框模块
				function initorder_sub() {
					$.get(wd_server.erp_work_order_sub_query, _data, function(res, status) {
						if(status == 'success') {
							if(res.code == 0) {
								var data = res.erp_work_order_sub
								var getTpl = forum_view_script.innerHTML,
									view = document.getElementById('forum_view');
									
								laytpl_sub(getTpl).render(data.data, function(html) {
									view.innerHTML = html;
								});
							} else {
								layer.msg(res.msg);
							}
							layer.closeAll('loading')
						} else {
							layer.msg('服务器连接错误');
							layer.closeAll('loading')
						}
					});
				}

				window.check = function(data) {
					if(data == 'people') {
						layer.open({
							type: 2,
							title: '选择',
							shadeClose: false,
							shade: 0.5,
							maxmin: true, //开启最大化最小化按钮
							area: ['800px', '90%'],
							content: '../../common/employee_list_one.html',
							end: function() {},
							success: function() {}
						});
					}
				}
				window.searchdata = function() {
				// alert(_data)
					layer.open({
						type: 2,
						title: '选择',
						shadeClose: false,
						shade: 0.5,
						maxmin: true, //开启最大化最小化按钮
						area: ['80%', '90%'],
						content: 'employee_list.html?orderid='+ _data.orderid,
						end: function() {},
						success: function(layero, index) {
							var body = layer.getChildFrame('body', index);
							body.find("input[name=report_to_userid]").val($('input[name=report_to_userid]').val());
				
						}
					});
				}
			});
		</script>
	</body>

</html>